from selenium import webdriver
from selenium.webdriver import Chrome
from selenium.webdriver.common.by import By
import time
import re

# 显示浏览器的自动化
#options = webdriver.ChromeOptions()
#options.add_experimental_option('excludeSwitches', ['enable-logging'])
#driver = webdriver.Chrome(options=options)
#driver = webdriver.Chrome()

# 不显示浏览器的自动化
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("headless")
driver = webdriver.Chrome(options = chrome_options)

driver.get('https://momoyu.cc')
result = driver.find_element(By.XPATH,'//*[@id="app"]/div[2]/div[2]/div[2]/p[1]/span[2]').text
driver.quit()  # 切记别忘了关进程！

sentences = re.split(r"([。！？])", result)
sentences.append("")
sentences = ["".join(i) for i in zip(sentences[0::2], sentences[1::2])]

# 直接在vscode里执行，txt会被保存到C:\Users\metasequoia下，在py文件的目录下打开cmd 执行python xxx.py就没这个问题！
fo = open("result.txt", "w+")
for x in sentences:
    fo.write(x+"\n")
fo.close()

print("\n\n\n")
for x in sentences:
    print(x)

input()